﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace NTTDATA.BEENChina.ResultCertification.Checker
{
    public class Verfity0303 : VerfityMulitResult
    {
        public override bool CheckResult(List<List<string>> result1, string entryCommon1, List<List<string>> result2, string entryCommon2)
        {
            if (result1 == null || result2 == null
                || result1.Count <= 0 || result2.Count <= 0
                || entryCommon1 == "30" || entryCommon2 == "30"
                )
            {
                return false;
            }
            
            for( int i=0;i<result1.Count ;i++)            
            {
                if (checkIsEmptyRow(result1, i) && ! checkIsEmptyRow(result2, i))
                {
                    return true;
                }
            }
            return false;
        }

        private bool checkIsEmptyRow(List<List<string>> result,int rowIndex)
        {
            if ( result  == null || result.Count <= rowIndex )
            {
                return false;
            }
            
            List<string> cols = result[rowIndex];
            if (cols != null && cols.All(o => string.Join("", o.Split(new char[] { '/' })) == string.Empty))
            {
                return true;
            }
            return false;
        }
    }
}